package studydome;

import java.util.Random;

public class 五位数随机 {
    public static void main(String[] args){
        //定义方法实现随机产生一个5位的验证码
        //验证码格式：
        //长度为5
        //清输入验证码
        //前四位是大写字母或者小写字母
        //最后一位是数字
        //        Random r =new Random();
        //        System.out.print( r.nextInt(10 ));
        //使用方法并打印验证码

        String yzm = get5Yzm();
        System.out.print("验证码为： "+yzm);
    }

    public static String get5Yzm(){
        char[] zm = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
                'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
        };
        //随机从zm数组中抽出字母组成验证码
        Random r =new Random();
        char frist = zm[r.nextInt(53)];
        char frist_2 = zm[r.nextInt(53)];
        char frist_3 = zm[r.nextInt(53)];
        char frist_4 = zm[r.nextInt(53)];

        //最后一个数是数字
        int last = r.nextInt(10);
        String yzm = frist + "" + frist_2 + "" + frist_3 + "" + frist_4 + "" + last;
        return yzm;
    }
}
